package spikes.button;

import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Random;

import javax.swing.JComponent;

@SuppressWarnings("serial")
public class MezzList extends JComponent {
	
	private ArrayList<MezzButton> buttons;
	
	public MezzList() {
		buttons = new ArrayList<MezzButton>();
		setLayout(null);
	}
	
	
	public void add(String name) {
		MezzButton b = new MezzButton(name, this);
		Rectangle r = new Rectangle();
		r.x = 0;
		r.y = buttons.size() * 40;
		r.height = 30;
		r.width = 200;
		b.setBounds(r);
		buttons.add(b);
		super.add(b);
	}
	
	public void setToFirst(MezzButton b) {
		//b.expand(500);
		
		remove(b);
		add(b);
		
		for (MezzButton button : buttons) 
			if (!button.isEnabled()) return;
		
		buttons.remove(b);
		buttons.add(0,b);
				
		for (int i = 0; i < buttons.size(); i++) {
			buttons.get(i).move(0, 40*i);
		}
	}
}
